﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace EffectLibrary {
    public class Easing {
        public enum Type {
            BackEase, BounceEase, CircleEase, CubicEase, ElasticEase, ExponentialEase, PowerEase,
            QuadraticEase, QuarticEase, QuinticEase, SineEase,
        }
        public class CustomEasing : EasingFunctionBase {
            Func<double,double> f1;
            public CustomEasing(Func<double,double> easeInCore) {
                this.f1 = easeInCore;
            }
            protected override double EaseInCore(double normalizedTime) {
                if (this.f1 != null)
                    return this.f1.Invoke(normalizedTime);
                else
                    return normalizedTime;
            }
        }

        public static EasingFunctionBase GetEasingFunction(Easing.Type type = Type.CubicEase,Func<double,double> func = null,EasingMode em = EasingMode.EaseIn) {
            dynamic t = null;
            if (func != null) {
                t = new CustomEasing(func);
                goto switchend;
            }
            switch (type) {
                case Type.BackEase:
                t = new BackEase();
                break;
                case Type.BounceEase:
                t = new BounceEase();
                break;
                case Type.CircleEase:
                t = new CircleEase();
                break;
                case Type.CubicEase:
                t = new CubicEase();
                break;
                case Type.ElasticEase:
                t = new ElasticEase();
                break;
                case Type.ExponentialEase:
                t = new ExponentialEase();
                break;
                case Type.PowerEase:
                t = new PowerEase();
                break;
                case Type.QuadraticEase:
                t = new QuadraticEase();
                break;
                case Type.QuarticEase:
                t = new QuarticEase();
                break;
                case Type.QuinticEase:
                t = new QuinticEase();
                break;
                case Type.SineEase:
                t = new SineEase();
                break;
                default:
                break;
            }
            switchend:
            if (t != null)
                t.EasingMode = em;
            return t;
        }

    }
}
